// Patch.h
#include <tchar.h>

#pragma once

enum PATCH_ACTION {
	PATCH_ACTION_WMPLAYER = 0,
	PATCH_ACTION_WMP = 1,
	PATCH_ACTION_2 = 2,
	PATCH_ACTION_SHELL32 = 3,
	PATCH_ACTION_OLE32 = 255
};

enum IMPORT_LIBRARY {
	IMPORT_LIBRARY_KERNEL32 = 0x1,
	IMPORT_LIBRARY_USER32 = 0x2,
	IMPORT_LIBRARY_MSVCRT = 0x8,
	IMPORT_LIBRARY_KERNEL32HOOK = 0x10,
	IMPORT_LIBRARY_API_LIBRARYLOADER = 0x40,
	IMPORT_LIBRARY_OLE32 = 0x80,
	IMPORT_LIBRARY_MF = 0x100,
};

#define WMPLAYEREXEA "wmplayer.exe"
#define WMPLAYEREXE _T(WMPLAYEREXEA)
#define USER32DLLA "USER32.DLL"
#define USER32DLL _T(USER32DLLA)
#define SHELL32DLLA "shell32.dll"
#define SHELL32DLL _T(SHELL32DLLA)
#define OLE32DLLA "ole32.dll"
#define OLE32DLL _T(OLE32DLLA)
#define WMVCOREDLLA "WMVCORE.DLL"
#define WMVCOREDLL _T(WMVCOREDLLA)
#define MSVCRTDLLA "MSVCRT.DLL"
#define MSVCRTDLL _T(MSVCRTDLLA)
#define PROPSYSDLLA "propsys.dll"
#define PROPSYSDLL _T(PROPSYSDLLA)
#define MFDLLA "MF.DLL"
#define MFDLL _T(MFDLLA)
#define KERNEL32DLLA "kernel32.dll"
#define KERNEL32DLL _T(KERNEL32DLLA)
#define APILIBRARYLOADERDLLA "API-MS-WIN-CORE-LIBRARYLOADER-L1-1-0.DLL"
#define APILIBRARYLOADERDLL _T(APILIBRARYLOADERDLLA)
#define QUARTZDLLA "quartz.dll"
#define QUARTZDLL _T(QUARTZDLLA)

extern LPCSTR kernel32Methods[];
extern const int kernel32Count;
extern LPCSTR user32Methods[];
extern const int user32Count;
extern LPCSTR mfMethods[];
extern const int mfCount;
extern LPCSTR msvcrtMethods[];
extern const int msvcrtCount;
extern LPCSTR ole32Methods[];
extern const int ole32Count;
extern LPCSTR apilibraryloaderMethods[];
extern const int apilibraryloaderCount;
extern LPCSTR propsysMethods[];
extern const int propsysCount;
extern LPCSTR shell32Methods[];
extern const int shell32Count;
extern LPCSTR wmvcoreMethods[];
extern const int wmvcoreCount;
extern const int wmpOrdinals[];
extern LPCSTR wmpMethods[];
extern const int wmpCount;
extern LPCSTR Kernel32Methods[];
extern const int Kernel32Count;
extern LPCSTR classObjectMethods[];
extern const int classObjectCount;
extern LPCSTR quartzExternals[];

extern void* user32Save[];
extern void* user32Patch[];
extern void* user32Hook[];
extern void* shell32Save[];
extern void* shell32Patch[];
extern void* shell32Hook[];
extern void* ole32Save[];
extern void* ole32Patch[];
extern void* ole32Hook[];
extern void* wmvcoreSave[];
extern void* wmvcorePatch[];
extern void* wmvcoreHook[];
extern void* msvcrtSave[];
extern void* msvcrtPatch[];
extern void* msvcrtHook[];
extern void* propsysSave[];
extern void* propsysPatch[];
extern void* propsysHook[];
extern void* mfSave[];
extern void* mfPatch[];
extern void* mfHook[];
extern void* Kernel32Save[];
extern void* Kernel32Patch[];
extern void* Kernel32Hook[];
extern void* quartzSave[];
extern void* quartzPatch[];
extern void* quartzHook[];

extern void* wmpSave[];
extern void* kernel32Patch[];
extern void* kernel32Save[];
extern void* apilibraryloaderSave[];

IMPORT_LIBRARY Patch(HMODULE handle, LPCTSTR path, PATCH_ACTION action);

BOOL WINAPI FreeLibraryHook(HMODULE hLibModule);
FARPROC WINAPI LoaderGetProcAddressHook(HMODULE hModule, LPCSTR lpProcName);
FARPROC WINAPI GetProcAddressHook(HMODULE hModule, LPCSTR lpProcName);
FARPROC WINAPI GetHookedProcAddress(HMODULE module, LPCSTR method);
HMODULE WINAPI GetModuleHandleAHook(LPCSTR lpModuleName);
HMODULE WINAPI GetModuleHandleWHook(LPCWSTR lpModuleName);
